﻿/******************************************************************
 * Copyright 2020-2022  NJUST Co. Ltd.
 * All right reserved. See COPYRIGHT for detailed Information.
 *
 * @file    HttpClientManager.h
 * @brief   封装面向服务端web api调用的服务接口
 *
 * @author  邹卫军
 * @brief   2022/12/02
 * @history
 ******************************************************************/

#ifndef HttpClientManager_H
#define HttpClientManager_H

#include <QObject>
#include <QMutex>
#include <QMutexLocker>
#include "Model/Base/MessageModel.h"
//#include "Model/Dto/ProbeCmdResult.h"
#include "Model/Dto/GeneralCmdResult.h"
//#include "Model/Dto/WarningRequest.h"
//#include "Model/Dto/DevRegRequest.h"
#include "Model/Dto/DevArvSearchResponse.h"
//#include "Model/Dto/DevLocationResponse.h"
//#include "Model/Dto/RfidMonitorRequest.h"
#include "Model/Dto/DevArvStatistics.h"
#include "Model/Dto/ArchiveRegisterRequest.h"
#include "Model/Base/ResponseModel.h"
#include "Controller/HttpClientController.h"
class HttpClientManager : public QObject
{
public:
    explicit HttpClientManager(QObject *parent = 0);

public:
    ~HttpClientManager();

    // 调用该类的接口函数，全局唯一
    static HttpClientManager *GetInstance()
    {
        static QMutex mutex; // 用于保证线程安全
        QMutexLocker locker(&mutex);
        if (_pInstance == NULL)
        {
            _pInstance = new HttpClientManager();
        }
        return _pInstance;
    }

private:
    static HttpClientManager *_pInstance;

    // 读取服务端地址
    QString urlBase = "192.168.1.105";//DeviceDBManager::getInstance()->getDeviceInfo("ServerUrl").toString();
    // HMI相关的web api接口地址
    const QString urlDev = QString("http://%1/DevRequest").arg(urlBase);
    const QString urlApi = QString("http://%1/api").arg(urlBase);

    // 封装Http的Get/Put/Post/Delete的操作
    HttpClientController _httpClientController;

public:
    // 设备端向服务端发送控制指令的响应报文
    ResponseModel PostGeneralCommandResult(GeneralCmdResult model);
//    // 设备端向服务端发送状态探测指令的响应报文
//    ResponseModel PostProbeCommandResult(ProbeCmdResult model);
//    // 设备端警告信息主动上报
//    ResponseModel PostDevWarningRequest(WarningRequest model);
//    // 设备端注册至调度系统
//    ResponseModel PostDevRegisterRequest(DevRegRequest model);
//    // 设备端上报当前层标签监控信息到服务端
//    ResponseModel PostDevRfidMonitorRequest(RfidMonitorRequest model);
      // 设备主动发起业务登记
      ResponseModel PostArchiveRegisterRequest(ArchiveRegisterRequest model);
//    // 设备端向服务端发送档案查询报文
    DevArvSearchResponse GetSearchArchives(QVariantMap  params);
//    // 设备端向服务端发送查询当前层档案报文
//    DevArvSearchResponse GetCurLayerArchives(int devNo, int layerNo, int pageIndex = 1, int pageSize = 20);
//    // 设备端向服务端发送查询当前货位报文
//    DevLocationResponse GetDevLocationInfo(int devNo, int layerNo);
    DevArvStatisticsModel GetDevArvStatistics();
    // 设备端向服务端发送查询设备Logo报文
//    QByteArray GetDevLogo();
};

#endif // HttpClientManager_H
